/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CastleDefense.Managers;

import CastleDefense.units.PlacedUnit;

/**
 *
 * @author Firedemon
 */
public class UpgradeManager
{
    public double getCurrentDamage(PlacedUnit unit)
    {        
        int    upgradeLevel   = getUpgradeLevel(unit);
        double upgradeAmmount = unit.getAtkMod();
        double unitDamage     = unit.getDamage();

        return (upgradeLevel*upgradeAmmount)+unitDamage;
    }

    public int getCurrentPoisonDamage()
    {
        int upgradeLevel   = UnitManager.getInstance().getArcheryLevel();
        int upgradeAmmount = 1;
        int poisonDamage   = 1;

        return (upgradeLevel*upgradeAmmount)+poisonDamage;
    }

    private int getUpgradeLevel(PlacedUnit unit)
    {
        if(unit.getUnitClass().equals("Archery"))
        {
            return UnitManager.getInstance().getArcheryLevel();
        }
        else if(unit.getUnitClass().equals("Magic"))
        {
            return UnitManager.getInstance().getMagicLevel();
        }
        else if(unit.getUnitClass().equals("Traps"))
        {
            return UnitManager.getInstance().getTrapLevel();
        }
        else if(unit.getUnitClass().equals("Hunter"))
        {
            return UnitManager.getInstance().getHunterLevel();
        }

        return 0;
    }
    
    public static final UpgradeManager getInstance() 
    {
        return SingletonHolder.instance;
    }
    
    @SuppressWarnings("synthetic-access")
    public static class SingletonHolder
    {
        protected static final UpgradeManager instance = new UpgradeManager();
    }
}
